package com.tsd.core.utils;

import java.util.Scanner;

/**
 * 设备标识工具栏
 *
 * @author wudw 2022-11-20
 */
public class DeviceIdUtil {
    /**
     * 是否Linux
     *
     * @return
     */
    public static Boolean isLinux() {
        String os = System.getProperty("os.name");
        return !os.toLowerCase().startsWith("win");
    }

    /**
     * 获取CPU序列号
     *
     * @return
     */
    public static String getCpuSerial() {
        String serial = null;
        try {
            Process process = Runtime.getRuntime().exec(new String[]{"wmic", "cpu", "get", "ProcessorId"});
            process.getOutputStream().close();
            Scanner sc = new Scanner(process.getInputStream());
            String property = sc.next();
            serial = sc.next();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return serial;
    }

    public static void main(String[] args) {
        String s = getCpuSerial();
        System.out.println(s);
    }
}
